import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../components/Index.vue'
import BookSquare from '../components/main/booksquare.vue'
import Searched from '../components/main/searchedbooks.vue'
import BookDetails from '../components/book/BookDetails.vue'
import Star from '../test/DinaStar.vue'
import Dina from '../test/DinaMenu.vue'
import father from '../test/test1.vue'
import son from '../test/test2.vue'
// import Navi from '../test/Navication.vue'

const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


Vue.use(VueRouter)
const routes = [
  {path: '/', redirect: '/index'},
  {path: '/index', component: Index, redirect: '/searched',children: [
    {path: '/book', component: BookSquare},
    {path: '/dina', component: Dina},
    {path: '/bookdetails', component: BookDetails},
    {path: '/searched', name: 'searched', component: Searched}
  ]},
  {path:'/star', component: Star},
  {path:'/father', component: father},
  {path:'/son', component: son}

]

const router = new VueRouter({
  mode: 'history',
  routes
})


export default router
